package com.zq.it.tool;

import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Set;

import net.sf.json.util.PropertyFilter;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ProFilter implements PropertyFilter {
	// Log log = LogFactory.getLog(this.getClass());
	private String[] fields=null;
    public ProFilter(String[] fields){
        this.fields = fields; 
    }

   public boolean apply(Object source, String name, Object value){
        if(fields != null && fields.length > 0) {
            if(juge(fields,name)) {  
                return true;  
            } else {  
                return false;  
            } 
        }
          
        return false;
    }
    /**
     * 过滤忽略的属性
     * @param s
     * @param s2
     * @return
     */
     public boolean juge(String[] s,String s2){  
         boolean b = false;  
         for(String sl : s){  
             if(s2.equals(sl)){  
                 b=true;  
             }  
         }  
         return b;  
     }  
    public String[] getFields() {
        return fields;
    }
  
    /**
     * 设置忽略的属性
     * @param fields
     */
    public void setFields(String[] fields) {
        this.fields = fields;
    }
}
